<?php

$auth = $_SESSION['auth'];
if (empty($auth)) die('用户未登录！');

if (empty($_GET['reply_id'])) die;

$reply_id = intval($_GET['reply_id']);

$reply = dt_query_one("SELECT topic_id, user_id FROM forum_topic_reply WHERE id = $reply_id"); 
if (!$reply) die('获取数据失败!');

require_once('inc/forum_city.php');
global $config;
if (1 > dt_count('forum', "WHERE id = (SELECT forum_id FROM forum_topic WHERE id = ".$reply['topic_id'].") AND user_id = ".$auth['id']) 
	&& $reply['user_id'] != $auth['id']
	&& !in_array($auth['id'], $config['manager'])
	&& dt_query_one("SELECT user_id FROM forum_city_info WHERE id = $forum_city")['user_id'] != $auth['id']) die('没有权限！^_^');

$rs = dt_query("DELETE FROM forum_topic_reply_up WHERE reply_id in (SELECT id FROM forum_topic_reply WHERE id = $reply_id)"); 
if (!$rs) die('回复赞数据变更失败!');
$rs = dt_query("DELETE FROM forum_topic_reply WHERE id = $reply_id"); 
if (!$rs) die('回复数据变更失败!');

put_info('删除成功！^_^');
header('Location:?c=forum&a=topic_show&topic_id='.$reply['topic_id']);
die;
